<?php
/*
*All rights reserved: Json.
*Links:http://www.liyaoquan.cn.
*Links:http://imarkchina.cn.
*Links:http://www.imarkchina.cn.
*/

/**
 * 博客前台列表模型，负责数据，增，删，改，查
 * 因为没有博客数据没使用数据库，所以没有继承 Model 类
 */
Class ListModel extends PublicModel{

	/**
	 * 处理列表数据
	 * @param  [type] $id [接收ID]
	 * @return [type]     [description]
	 */
	Public function getList($id){
		$C = $this->blogConfig();
		$file = loadfile(C('post.postid').$id.'.php');
		$temp = array();
		foreach ($file as $k => $v) {
			$temp[][$k] = $v;
		}
		$indexpage = $C['site_mumber'];
		$count = count($temp);
		$pageurl = U('list/index', array('lid' => $id), true);
		$page = new Page($count, $indexpage, $pageurl);
		$pnum = explode(',', $page->limit());
		$array = array();
		for ($i=0; $i < $count; $i++) {
			if ($i < $pnum[0] || $i >= $pnum[0] + $pnum[1]) continue;
			$array[] = $temp[$i];
		}
		$array = Arr::getArray($array);
		$lastarr = array();
		foreach ($array as $k => $v) {
				$lastarr[] = unfile(C('post.postdata').$k.'.Mark');
			}
		$lidfile = loadfile(C('post.listid'));
		$redata['check'] = $this->CheckIsOpen();
		$redata['lid'] = $lidfile[$id];
		$redata['list'] = $lastarr;
		$redata['page'] = $page->view();
		return $redata;
	}
}